package pong.game.objects;

import pong.game.WifiType;
import pong.general.GameWindow;

import android.graphics.Bitmap;

public class Washer extends Range
{
	private float				minimalSpeed;
	private static final float	staticMinimalSpeedslowness 	= 0.005f;
	private static final float	slowness 					= 0.0005f;
	private static final float  maximalSpeed 				= 0.01f;
	public 		Washer(Bitmap washer)
	{
		super(washer);
		dir.x = (float) ((Math.random()*1000)%1000);
		dir.y = (float) ((Math.random()*1000)%1000);
		dir.normalize();
		slow();
		minimalSpeed = staticMinimalSpeedslowness;
	}
	public void setTime(long time)
	{
		minimalSpeed = staticMinimalSpeedslowness * time/10;
	}

	public 		Washer(Bitmap washer, WifiType wifiType, float X, float Y, float radius)
	{
		super(washer, wifiType, X, Y, radius);
		dir.x = (float) ((Math.random()*1000)%1000);
		dir.y = (float) ((Math.random()*1000)%1000);
		dir.normalize();
		slow();
		minimalSpeed = staticMinimalSpeedslowness;
	}
	public 		Washer(Bitmap washer, WifiType wifiType, float X, float Y)
	{
		super(washer, wifiType, X, Y);
		dir.x = (float) ((Math.random()*1000)%1000);
		dir.y = (float) ((Math.random()*1000)%1000);
		dir.normalize();
		slow();
		minimalSpeed = staticMinimalSpeedslowness;
	}
	
	void 		slow()
	{
		float length = dir.getVecLength();
		if(length < minimalSpeed)
		{
			dir.normalize();
			dir.multy(minimalSpeed);
		}
		length = dir.getVecLength();
		if(length > maximalSpeed)
		{
			dir.divide(length);
			dir.multy(maximalSpeed);
		}
	}

}
